<?php

$_this =& $this;

/* @var $_this View */
/* @var $form FormHelper */
/* @var $editForm EditFormHelper */
/* @var $html HtmlHelper */
/* @var $ehtml EHtmlHelper */
/* @var $javascript JavascriptHelper */
/* @var $jqax JqaxHelper */
/* @var $filterBlock FilterBlock */

?><?=$editForm->create($modelName, array('url'=>("/{$url_part}/".($mode == 'create' ? 'new' : $this->data[$modelName]['id']).'/'), 'allowInput' => $this->data[$modelName]['__allows']['update']));?><?php

    if ($mode !== 'create') {
    	?><?=$editForm->startSet();?><?php
        	?><?=$editForm->datetime("created", __d($po_domain, 'created_field', true), array('allowInput' => false));?><?php
            $editForm->data[$modelName]['currency'] = "EP";
    		?><?=$editForm->amount(array("balance", "currency"), __d($po_domain, 'account_title', true), array("EP" => "EP"), array('allowInput' => false));?><?php
    	?><?=$editForm->endSet();?><?php
    }

	?><?=$editForm->startSet(__d($po_domain, 'organization_title', true));?><?php
		?><?=$editForm->text("name", __d($po_domain, 'name', true), array('required' => true, 'vertical' => false));?><?php
		?><?=$editForm->text("contract", __d($po_domain, 'contract', true), array('required' => true, 'vertical' => false));?><?php
		?><?=$editForm->date("contract_start_date", __d($po_domain, 'contract_start_date', true), array('required' => true));?><?php
		?><?=$editForm->date("contract_finish_date", __d($po_domain, 'contract_finish_date', true), array('required' => true));?><?php
		?><?=$editForm->text("reg_code", __d($po_domain, 'reg_code', true), array('required' => true, 'vertical' => false));?><?php

        $checkboxes = '';
        foreach ($tools_list as $id=>$label) {
            $checkboxes .= '<input id="'.$modelName.'Tools'.$id.'" type="checkbox" name="data['.$modelName.'][tools][]"';
            $checkboxes .= ' value="'.$id.'"';
            in_array($id, $this->data[$modelName]["tools"]) ? $checkboxes .= ' checked="checked"' : false;
            $checkboxes .= ' />';
            $checkboxes .= '<label for="'.$modelName.'Tools'.$id.'">'.$label.'</label><br />';
        }
        ?><?=$editForm->cell($checkboxes);?><?php

	?><?=$editForm->endSet();?><?php

	?><?=$editForm->startSet(__d($po_domain, 'contact_person', true));?><?php
		?><?=$editForm->text("contact_person_name", __d($po_domain, 'contact_person_name', true), array('required' => true, 'vertical' => false));?><?php
		?><?=$editForm->text("contact_person_city", __d($po_domain, 'contact_person_city', true), array('required' => true, 'vertical' => false));?><?php
		?><?=$editForm->text("contact_person_tel", __d($po_domain, 'contact_person_tel', true), array('required' => true, 'vertical' => false));?><?php
		?><?=$editForm->text("contact_person_email", __d($po_domain, 'contact_person_email', true), array('required' => true, 'vertical' => false));?><?php
		?><?=$editForm->textarea("contact_person_juridical_address", __d($po_domain, 'contact_person_juridical_address', true), array('vertical' => false));?><?php
	?><?=$editForm->endSet();?><?php

	$buttonsHTML = '';
	$buttonsHTML .= (strlen($buttonsHTML) ? ' ' : '').$editForm->back("/{$url_part}/");
	if ($this->data[$modelName]['__allows']['update']) {
	   $buttonsHTML .= (strlen($buttonsHTML) ? ' ' : '').$editForm->submit(__d(null, ($mode == 'create' ? 'create' : 'save'), true), array());
	}
	if (strlen($buttonsHTML)) {
    	?><?=$editForm->cell($buttonsHTML);?><?php
	}

?><?=$editForm->end();?><?php

?>